
package com.mp.chart.renderer;

import android.graphics.Canvas;

import com.mp.chart.animation.ChartAnimator;
import com.mp.chart.data.LineDataSet;
import com.mp.chart.interfaces.AJProvider;
import com.mp.chart.interfaces.LineDataProvider;
import com.mp.chart.utils.Highlight;
import com.mp.chart.utils.ViewPortHandler;

/**
 * k线柱状图高亮
 */
public class AJLineChartRenderer extends LineChartRenderer {


    private final AJProvider marketChart;

    public AJLineChartRenderer(LineDataProvider chart, ChartAnimator animator, ViewPortHandler viewPortHandler) {
        super(chart, animator, viewPortHandler);
        marketChart= (AJProvider) chart;
    }
/*画高亮线*/
    @Override
    public void drawHighlighted(Canvas c, Highlight[] indices) {

        if(marketChart.getHighLightStyle()){
            super.drawHighlighted(c,indices);
        }else {
            for (int i = 0; i < indices.length; i++) {

                LineDataSet set = mChart.getLineData().getDataSetByIndex(indices[i]
                        .getDataSetIndex());

           /*     if (set == null || !set.isHighlightEnabled())
                    continue;*/

                mHighlightPaint.setColor(set.getHighLightColor());
                int xIndex = indices[i].getXIndex(); // get the
//                Log.e("####",xIndex+"~~~"+indices[i].getValuePosition()+","+indices[i].getStackIndex());
                // x-position

              /*  if (xIndex > mChart.getXChartMax() * mAnimator.getPhaseX())
                    continue;*/

                final float yVal = set.getYValForXIndex(xIndex);
             /*   if (yVal == Float.NaN)
                    continue;*/

//            float y = yVal * mAnimator.getPhaseY(); // get
                // the
                // y-position

                float[] pts = new float[]{
                        xIndex, mChart.getYChartMax(), xIndex, mChart.getYChartMin()
                };

                mChart.getTransformer(set.getAxisDependency()).pointValuesToPixel(pts);
                // draw the highlight lines
                c.drawLines(pts, mHighlightPaint);
            }

        }
    }
}
